package org.bilinc.gz001.dao;


import org.bilinc.gz001.dao.interfaces.AbstractDaoImpl;
import org.bilinc.gz001.dao.interfaces.ICityDao;
import org.bilinc.gz001.entity.City;
import org.bilinc.gz001.hibernateUtil.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class CityDao extends AbstractDaoImpl<City> implements ICityDao {

    CityDao() {
    }

    public City findByName(String cityName) {
        City city =  (City) getSession().createCriteria(City.class).add(Restrictions.eq("city", cityName)).uniqueResult();
        closeSession();
        return city;
    }
}
